//
//  NYNavigationViewController.m
//  Nooryes
//
//  Created by baken on 2020/2/18.
//  Copyright © 2020 MyApp. All rights reserved.
//

#import "NYNavigationViewController.h"
#import "UIImage+Render.h"
#import "NYSearchViewController.h"

@interface NYNavigationViewController ()<UIGestureRecognizerDelegate>

@end

@implementation NYNavigationViewController


+ (void)load{
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}];
    [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(kAllWhiteColor)];
    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
//    [[UINavigationBar appearance] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
     
}

- (void)viewDidLoad {
    [super viewDidLoad];

}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count) {
        viewController.hidesBottomBarWhenPushed = YES;
        
    
         UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
         [backButton setImage:[UIImage imageNamed:@"tit_return"] forState:UIControlStateNormal];
         [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
         [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
         [backButton sizeToFit];
         
         // 注意:一定要在按钮内容有尺寸的时候,设置才有效果
//         backButton.contentEdgeInsets = UIEdgeInsetsMake(0, -25, 0, 0);
         
         // 设置返回按钮
//        if (![viewController isKindOfClass:[NYSearchViewController class]]) {
            viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
//        }
    }
    [super pushViewController:viewController animated:animated];
}

-(void)back{
     [self popViewControllerAnimated:YES];
}

@end
